function cum_Vtime_j_14 = Calculate_V_function(cum_Dtime_j_14)

global epsilon_weekday epsilon_weekend kappa ncity E_weekday E_weekend w d_GIS delta_j

d_GIS(:,26)=0;
cum_Dtime_j_14(26)=0; % home sector

    for a=1:2
    for d1=1:ncity
        for d2=1:ncity+1
            d(d1,d2,a)=exp(kappa*d_GIS(d1,d2));
        end
    end
    end
    % choosing top destination during weekdays
    for a=1:2
    for d1=1:ncity
        % calculate sum
        sum_denominator=0;
        for d2=1:ncity+1
            sum_denominator=sum_denominator+E_weekday(d2,a)*(w(d2,a)/d(d1,d2,a))^epsilon_weekday;
        end
        for d2=1:ncity+1
            pi(d1,d2)=E_weekday(d2,a)*(w(d2,a)/d(d1,d2,a))^epsilon_weekday/sum_denominator;
        end
        pi(d1,d1)=0; % ignore living location
        pi(d1,26)=0; % ignore home sector
        [max_pi(d1,a) visit_weekdays(d1,a)]=max(pi(d1,:));
    end
    % choosing top destination during weekends
    for d1=1:ncity
        % calculate sum
        sum_denominator=0;
        for d2=1:ncity+1
            sum_denominator=sum_denominator+E_weekend(d2,a)*(1/d(d1,d2,a))^epsilon_weekend;
        end
        for d2=1:ncity+1
            pi(d1,d2)=E_weekend(d2,a)*(1/d(d1,d2,a))^epsilon_weekend/sum_denominator;
        end
        pi(d1,d1)=0; % ignore living location
        pi(d1,26)=0; % ignore home sector
        [max_pi(d1,a) visit_weekends(d1,a)]=max(pi(d1,:));
    end
    end
    
    cum_Vtime_j_14=zeros(ncity,1);
    for a=1:2
    for d1=1:ncity
        cum_Vtime_j_14(visit_weekdays(d1,a))=cum_Vtime_j_14(visit_weekdays(d1,a))+1/4*cum_Dtime_j_14(d1); % top destination in weekdays
        cum_Vtime_j_14(visit_weekends(d1,a))=cum_Vtime_j_14(visit_weekends(d1,a))+1/4*cum_Dtime_j_14(d1); % top destination in weekends
    end
    end
    % with X amount of cases, this generates X amount of visits
end